home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 February: Tool Chest / Dev.CD Feb 95 / Dev.CD Feb 95.toast / Sample Code / Newton Sample Code 1.2 / User Interface Guidelines / Splash-1 / Splash.text < prev    next >
Encoding:
Text File  |  1994-07-05  |  11.6 KB  |  443 lines  |  [TEXT/MPS ]

  1.  
  2. // ---- End Project Data ----
  3.  
  4.  
  5. // ---- File The Application.t ----
  6.  
  7. // Before Script for "theApp"
  8. // Copyright © 1994 by Apple Computer, Inc.  All rights reserved.
  9.  
  10. // Note that this view is NOT initially visible.  This keeps it from
  11. // appearing as a child in the application.  Because it is linked to
  12. // the app and declared, the template will be available to the code.
  13.  
  14. theApp :=
  15.    {title: "Splash Screen Demo",
  16.     viewBounds: {left: 0, top: 2, right: 236, bottom: 334},
  17.     viewFormat: 328017,
  18.     viewSetupFormScript:
  19.       func()
  20.       begin
  21.          // open the splash screen
  22.           mySplashScreen := BuildContext(theSplashScreen._proto);
  23.           mySplashScreen:Open();  // because it's initially invisible
  24.           RefreshViews(); // make the screen update
  25.           
  26.           mySplashScreen:UpdateStatus("Initializing...");
  27.           
  28.           // do the rest of the view setup
  29.          local a := GetAppParams();
  30.          constant kMaxAppWidth := 240;
  31.          constant kMaxAppHeight := 336;
  32.          self.viewBounds := RelBounds(a.appAreaLeft, a.appAreaTop,
  33.                                                MIN(a.appAreaWidth, kMaxAppWidth),
  34.                                                MIN(a.appAreaHeight, kMaxAppHeight));
  35.          
  36.           mySplashScreen:UpdateStatus("Wasting Time...");
  37.          // waste some time (inefficiently--to simulate a real app processing)                            
  38.            for i := 1 to 100 do
  39.                sleep(1);          
  40.       end,
  41.     viewSetupChildrenScript:
  42.       func()
  43.       begin
  44.             mySplashScreen:UpdateStatus("Waisting More Time...");
  45.          // waste some time (inefficiently--to simulate a real app processing)                            
  46.            for i := 1 to 100 do
  47.                sleep(1);          
  48.       end,
  49.     viewSetupDoneScript:
  50.       func()
  51.       begin
  52.           mySplashScreen:UpdateStatus("Last Bit of Waste...");
  53.          // waste some time (inefficiently--to simulate a real app processing)                            
  54.            for i := 1 to 100 do
  55.                sleep(1);
  56.                
  57.            // Finally... put the splash screen away.
  58.            AddDeferredAction(CloseSplashScreen, []);
  59.       end,
  60.     mySplashScreen: nil,
  61.     viewQuitScript:
  62.       func()
  63.       begin
  64.           // in case close happens unexpectedly (card yanking, auto close)
  65.           // close the splash screen, use :? in case it's NIL
  66.           mySplashScreen:?Close();
  67.           
  68.           // always nil out slots that may have big things in them.
  69.           mySplashScreen := nil;
  70.       end,
  71.     CloseSplashScreen:
  72.       func()
  73.       begin
  74.            mySplashScreen:?Close();
  75.            mySplashScreen := NIL;
  76.       end,
  77.     AppInfoItems: ["About"],
  78.     declareSelf: 'base,
  79.     InfoItemSelected:
  80.       func(item)
  81.       begin
  82.           // this is where you respond to the info button
  83.           // see the pickActionScript in the protoInfoButton to
  84.           // to see where this script is called from.
  85.           
  86.           // see the infoButton sample for details on protoInfoButton
  87.       
  88.           // open up the About view
  89.           // but make sure the close box shows
  90.           theSplashScreen.hideCloseBoxP := nil ;
  91.           theSplashScreen:Open();
  92.       
  93.       end,
  94.     viewFlags: 4,
  95.     viewclass: 74,
  96.     debug: "theApp"
  97.    };
  98.  
  99. _view000 := /* child of theApp */
  100.    {text: "THIS SPACE INTENTIONALLY LEFT BLANK",
  101.     viewBounds: {left: 8, top: 120, right: 232, bottom: 144},
  102.     viewJustify: 8388614,
  103.     _proto: protoStaticText
  104.    };
  105.  
  106.  
  107.  
  108. // ---- File The Splash Screen.t ----
  109.  
  110. // Before Script for "theSplashScreen"
  111. // Copyright © 1994 by Apple Computer, Inc.  All rights reserved.
  112.  
  113. // Note that this view is NOT initially visible.  This keeps it from
  114. // appearing as a child in the application.  Because it is linked to
  115. // the app and declared, the template will be available to the code.
  116.  
  117. theSplashScreen := /* child of theApp */
  118.    {viewFlags: 0,
  119.     viewFormat: 131665,
  120.     viewBounds: {left: 0, top: 0, right: 240, bottom: 336},
  121.     viewSetupFormScript:
  122.       func()
  123.       begin
  124.          local a := GetAppParams();
  125.          constant kMaxAppWidth := 240;
  126.          constant kMaxAppHeight := 336;
  127.          self.viewBounds := RelBounds(a.appAreaLeft + 4, a.appAreaTop + 4,
  128.                                                MIN(a.appAreaWidth, kMaxAppWidth) - 8,
  129.                                                MIN(a.appAreaHeight, kMaxAppHeight) - 8);
  130.       end,
  131.     viewEffect: 8521952,
  132.     hideCloseBoxP: true,
  133.     viewSetupDoneScript:
  134.       func()
  135.       begin
  136.           if hideCloseBoxP then
  137.               SplashClose:Hide();
  138.       end,
  139.     declareSelf: 'base,
  140.     UpdateStatus:
  141.       func(message)
  142.       begin
  143.           // change the status text
  144.           SetValue(StatusMessage, 'text, message) ;
  145.           RefreshViews()
  146.       end,
  147.     viewclass: 74,
  148.     debug: "theSplashScreen"
  149.    };
  150. // View theSplashScreen is declared to theApp
  151.  
  152. AboutPic := /* child of theSplashScreen */
  153.    {viewFlags: 1,
  154.     icon: GetPictAsBits("newt 300", nil),
  155.     viewFormat: nil,
  156.     viewBounds: {left: 0, top: 20, right: 120, bottom: 120},
  157.     viewJustify: 22,
  158.     viewclass: 76,
  159.     debug: "AboutPic"
  160.    };
  161.  
  162.  
  163.  
  164. text1 := /* child of theSplashScreen */
  165.    {viewFlags: 1,
  166.     viewFormat: 0,
  167.     viewlinespacing: 20,
  168.     viewFont: {family: 'newYork, face: kFaceNormal, size: 18},
  169.     viewBounds: {left: 0, top: 5, right: 0, bottom: 30},
  170.     text: "Info Button Sample!",
  171.     viewJustify: 8374,
  172.     viewclass: 81,
  173.     debug: "text1"
  174.    };
  175.  
  176.  
  177.  
  178. text2 := /* child of theSplashScreen */
  179.    {viewFlags: 1,
  180.     viewFormat: 0,
  181.     viewlinespacing: 12,
  182.     viewFont: {family: 'newYork, face: kFaceNormal, size: 10},
  183.     viewBounds: {top: 5, left: 10, right: -10, bottom: 33},
  184.     text: "Copyright \u00A9\u 1994 Apple Computer, Inc., All Rights Reserved.",
  185.     viewJustify: 8374,
  186.     viewclass: 81,
  187.     debug: "text2"
  188.    };
  189.  
  190.  
  191.  
  192. text3 := /* child of theSplashScreen */
  193.    {viewFlags: 1,
  194.     viewFormat: 0,
  195.     viewlinespacing: 11,
  196.     viewFont: {family: 'espy, face: kFaceNormal, size: 9},
  197.     viewBounds: {top: 5, left: 20, right: -20, bottom: 78},
  198.     viewJustify: 8374,
  199.     text:
  200.       "This sample gives you a proto you can use for the info button in your application. It was written at great expense at the last minute by a specially trained team of Peruvian Llamas. However, my boss will not let me say\nthat, so I have to take the credit."
  201.     ,
  202.     viewclass: 81,
  203.     debug: "text3"
  204.    };
  205.  
  206.  
  207.  
  208. text4 := /* child of theSplashScreen */
  209.    {viewFlags: 1,
  210.     viewFormat: 0,
  211.     viewlinespacing: 12,
  212.     viewFont: {family: 'newYork, face: kFaceNormal, size: 10},
  213.     viewBounds: {top: 0, left: 10, right: -10, bottom: 25},
  214.     text: "P.S., Have you hugged your Llama today?",
  215.     viewJustify: 8374,
  216.     viewclass: 81,
  217.     debug: "text4"
  218.    };
  219.  
  220.  
  221.  
  222. SplashClose := /* child of theSplashScreen */
  223.    {_proto: protoClosebox, debug: "SplashClose"};
  224. // View SplashClose is declared to theSplashScreen
  225.  
  226.  
  227.  
  228. StatusMessage := /* child of theSplashScreen */
  229.    {text: "",
  230.     viewBounds: {top: -20, left: 0, right: -20, bottom: 0},
  231.     viewJustify: 8388788
  232.     ,
  233.     _proto: protoStaticText,
  234.     debug: "StatusMessage"
  235.    };
  236. // View StatusMessage is declared to theSplashScreen
  237.  
  238.  
  239.  
  240.  
  241. // ---- Back in File The Application.t ----
  242.  
  243. _view001 := /* child of theApp */
  244.    {viewBounds: {left: 0, top: 0, right: 104, bottom: 16}, _proto: protoTitle};
  245.  
  246.  
  247.  
  248. _view002 := /* child of theApp */ {_proto: protoStatus};
  249.  
  250.  
  251. // ---- File protoInfoButton ----
  252. info :=
  253.    {viewBounds: {left: 17, top: 0, right: 30, bottom: 12},
  254.     viewFormat: 67109457,
  255.     pickCancelledScript:
  256.       func()
  257.       begin
  258.           :Hilite(nil);
  259.       end,
  260.     icon: GetPictAsBits("info icon", nil),
  261.     viewClickScript:
  262.       func(unit)
  263.       begin
  264.           if :TrackHilite(unit) then
  265.           begin
  266.               local l := :LocalBox();
  267.       
  268.               DoPopUp(AppInfoItems, l.right+3, l.top, self);
  269.           end;
  270.       end,
  271.     viewFlags: 513,
  272.     viewclass: 76,
  273.     debug: "info"
  274.    };
  275.  
  276. // After Script for "info"
  277. thisView := info;
  278. // Copyright ©1994 Apple Computer, Inc., All Rights Reserved.
  279. // set the bounds of the button so that it is to the right
  280. // of the clock and the correct height for the status bar
  281.  
  282. // NOTE: this is the first button, so argument to the
  283. // ButtonBounds function MUST be negative
  284. thisView.viewBounds := ButtonBounds(-(thisView.viewBounds.right - thisView.viewBounds.left));
  285.  
  286.  
  287. // ---- Back in File The Application.t ----
  288. _view003 := /* child of _view002 */
  289.    {
  290.     pickActionScript:
  291.       func(index)
  292.       begin
  293.           // MUST do this
  294.           :Hilite(nil);
  295.       
  296.           :InfoItemSelected(index) ;
  297.       end,
  298.     _proto: info
  299.    };
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309. // ---- Beginning of section for non used Layout files ----
  310.  
  311. // ---- File The Splash Screen.t ----
  312.  
  313. // Before Script for "SplashBase"
  314. // Copyright © 1994 by Apple Computer, Inc.  All rights reserved.
  315.  
  316. // Note that this view is NOT initially visible.  This keeps it from
  317. // appearing as a child in the application.  Because it is linked to
  318. // the app and declared, the template will be available to the code.
  319.  
  320. SplashBase :=
  321.    {viewFlags: 0,
  322.     viewFormat: 131665,
  323.     viewBounds: {left: 0, top: 0, right: 240, bottom: 336},
  324.     viewSetupFormScript:
  325.       func()
  326.       begin
  327.          local a := GetAppParams();
  328.          constant kMaxAppWidth := 240;
  329.          constant kMaxAppHeight := 336;
  330.          self.viewBounds := RelBounds(a.appAreaLeft + 4, a.appAreaTop + 4,
  331.                                                MIN(a.appAreaWidth, kMaxAppWidth) - 8,
  332.                                                MIN(a.appAreaHeight, kMaxAppHeight) - 8);
  333.       end,
  334.     viewEffect: 8521952,
  335.     hideCloseBoxP: true,
  336.     viewSetupDoneScript:
  337.       func()
  338.       begin
  339.           if hideCloseBoxP then
  340.               SplashClose:Hide();
  341.       end,
  342.     declareSelf: 'base,
  343.     UpdateStatus:
  344.       func(message)
  345.       begin
  346.           // change the status text
  347.           SetValue(StatusMessage, 'text, message) ;
  348.           RefreshViews()
  349.       end,
  350.     viewclass: 74,
  351.     debug: "SplashBase"
  352.    };
  353.  
  354. AboutPic := /* child of SplashBase */
  355.    {viewFlags: 1,
  356.     icon: GetPictAsBits("newt 300", nil),
  357.     viewFormat: nil,
  358.     viewBounds: {left: 0, top: 20, right: 120, bottom: 120},
  359.     viewJustify: 22,
  360.     viewclass: 76,
  361.     debug: "AboutPic"
  362.    };
  363.  
  364.  
  365.  
  366. text1 := /* child of SplashBase */
  367.    {viewFlags: 1,
  368.     viewFormat: 0,
  369.     viewlinespacing: 20,
  370.     viewFont: {family: 'newYork, face: kFaceNormal, size: 18},
  371.     viewBounds: {left: 0, top: 5, right: 0, bottom: 30},
  372.     text: "Info Button Sample!",
  373.     viewJustify: 8374,
  374.     viewclass: 81,
  375.     debug: "text1"
  376.    };
  377.  
  378.  
  379.  
  380. text2 := /* child of SplashBase */
  381.    {viewFlags: 1,
  382.     viewFormat: 0,
  383.     viewlinespacing: 12,
  384.     viewFont: {family: 'newYork, face: kFaceNormal, size: 10},
  385.     viewBounds: {top: 5, left: 10, right: -10, bottom: 33},
  386.     text: "Copyright \u00A9\u 1994 Apple Computer, Inc., All Rights Reserved.",
  387.     viewJustify: 8374,
  388.     viewclass: 81,
  389.     debug: "text2"
  390.    };
  391.  
  392.  
  393.  
  394. text3 := /* child of SplashBase */
  395.    {viewFlags: 1,
  396.     viewFormat: 0,
  397.     viewlinespacing: 11,
  398.     viewFont: {family: 'espy, face: kFaceNormal, size: 9},
  399.     viewBounds: {top: 5, left: 20, right: -20, bottom: 78},
  400.     viewJustify: 8374,
  401.     text:
  402.       "This sample gives you a proto you can use for the info button in your application. It was written at great expense at the last minute by a specially trained team of Peruvian Llamas. However, my boss will not let me say\nthat, so I have to take the credit."
  403.     ,
  404.     viewclass: 81,
  405.     debug: "text3"
  406.    };
  407.  
  408.  
  409.  
  410. text4 := /* child of SplashBase */
  411.    {viewFlags: 1,
  412.     viewFormat: 0,
  413.     viewlinespacing: 12,
  414.     viewFont: {family: 'newYork, face: kFaceNormal, size: 10},
  415.     viewBounds: {top: 0, left: 10, right: -10, bottom: 25},
  416.     text: "P.S., Have you hugged your Llama today?",
  417.     viewJustify: 8374,
  418.     viewclass: 81,
  419.     debug: "text4"
  420.    };
  421.  
  422.  
  423.  
  424. SplashClose := /* child of SplashBase */
  425.    {_proto: protoClosebox, debug: "SplashClose"};
  426. // View SplashClose is declared to SplashBase
  427.  
  428.  
  429.  
  430. StatusMessage := /* child of SplashBase */
  431.    {text: "",
  432.     viewBounds: {top: -20, left: 0, right: -20, bottom: 0},
  433.     viewJustify: 8388788
  434.     ,
  435.     _proto: protoStaticText,
  436.     debug: "StatusMessage"
  437.    };
  438. // View StatusMessage is declared to SplashBase
  439.  
  440.  
  441.  
  442.  
  443. // End of output